<template>
  <div class="about">
    <h1>This is an about page</h1>
    <button @click="s()">点击</button>
    <div>
      {{ a }}s神s
     
    </div>
    <div v-for="(item,index) in c" :key="item.id">
       {{ sb[index] }}
      <button @click="sss(index,item.id)">
        点击
      </button>
      {{item.a}}ssa {{item.id}}神indddex{{index}}
       <button @click="ssss(index,item.id)">
        点击
      </button>
    </div>
     <input type="text" v-model="f">
    <button @click="glq()">搜索</button>
     <div v-for="(itema,indexa) in e" :key="itema.id">
      <button @click="ssss(indexa,item.id)">
        点击
      </button>
      {{itema.name}}
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      a: 3,
      b: 1,
      c:[
        {
          a:0,
          b:1,
          id:0
        },
        {
          a:1,
          b:1,
          id:1
        },
         {
          a:2,
          b:2,
           id:2

        }
        , {
          a:'a',
          b:3,
           id:3
        }
      ],
      d:[
        {
          name:'天天快跑',
         id:100
        },
        {
          name:'3天快跑',
           id:101
        },
         {
          name:'天快跑',
           id:102
        },
         {
          name:'快跑',
           id:103
        },
         {
          name:'3天快',
           id:104
        },
        {
          name:'啊大大',
           id:105
        },
      ],
      e:[
      ],
      f:''
    };
  },
  computed: {
    sb() {
      // this.b
      console.log(111)
      return this.c
    },
  },
  methods: {
    s() {
      this.a++;
        this.b++;
      this.c.push( {
          a:'b',
           id:this.a
        })
      // for(let d of this.c ){
      //   console.log(d.a)
      // }
      console.log(this.sb);
    },
    sss(index,id){
      console.log(id)
      this.c.splice(index,1)
      console.log(this.c)
    },
    ssss(index,id){
      console.log(id)
      //this.c.splice(index,1)
      console.log(index)
    },
    glq(){
     
    this.e  = this.d.filter((value,index,arr)=>{
       let c=[]
        if(value.name.indexOf(this.f)!=-1){
           c.push(value)
            console.log(c)
            return c
           
        }
       
      
      })
       
    }
  },
};
</script>
